package com.thinkcube.edutainment.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.thinkcube.edutainment.R;

public class IndexAdapter extends ArrayAdapter<String>{
	Context context;
	ArrayList<String> indexes;
	int selectedIntdex;
	public IndexAdapter(Context context, String[] values, ArrayList<String> indexes) {
		super(context, R.layout.lesson_item, values);
		this.context=context;
		this.indexes=indexes;
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    View rowView = inflater.inflate(R.layout.lesson_bar_item, parent, false);
	    TextView indexView=(TextView) rowView.findViewById(R.id.lesson_title);
	    indexView.setText(indexes.get(position).toString());
	    
	    if(selectedIntdex!= -1 && position == selectedIntdex)
        {
	    	//view.setBackgroundColor(Color.BLACK);
	    	rowView.setBackgroundResource(R.drawable.nav_active);
        }
        else
        	
        {
        	rowView.setBackgroundResource(Color.TRANSPARENT);
        }
		return rowView;
	}
	
	public void setSelectedItem(int ind) {
		selectedIntdex =ind;
		notifyDataSetChanged();
		
	}
}